<template>
	<view class="idSafe">
		<view class="warp">
		<view class="box" @click="changeHead">
			<!-- <view class="page">
			            <view class="content">
			                <fjj-images title="图片上传示例" :pageImgList="imgList" :imgCount="9" @addImg="editParkImg"
			                @deleteImg="deleteImg"></fjj-images>
			            </view>
			        </view> -->
			<h3>{{$t('systen.idSafe.headImg')}}</h3>
			<image :src="src" mode="aspectFit" class="headT"></image>
			<image src="../../static/get/go.png" mode="" class="go"></image>
		</view>
		<view class="box" @click="changeTel">
			<h3>{{$t('systen.idSafe.tel')}}</h3>
			<text class="tel">{{tel}}</text>
			<image src="../../static/get/go.png" mode="" class="go"></image>
		</view>
		<view class="box" @click="changeAddress">
			<h3>{{$t('mine.teamLeader.address')}}</h3>
			<text class="address">陕西省西安市</text>
			<image src="../../static/get/go.png" mode="" class="go"></image>
		</view>
		<view class="box" @click="changeWalletaddresss(user_data.walletaddresss)">
			<h3>{{$t('mine.teamLeader.Wallet')}}</h3>
			<text class="address"></text>
			<image src="../../static/get/go.png" mode="" class="go"></image>
		</view>
		</view>
	</view>
</template>

<script>
	import api from '../../common/api.js'
	import config from '../../common/config.js'
  import fjjImages from '@/components/fjj-images/fjj-images.vue';	
	export default {
		components:{
			fjjImages
		},
		data() {
			return {
				src:'',
				tel:'',
				token:'',
				user_data: '',
				imgList: ['https://ossweb-img.qq.com/images/lol/web201310/skin/big10001.jpg'],
			}
		},
		methods: {
			changeWalletaddresss(val) {
				uni.navigateTo({
					url: '/pages/Walletaddresss/Walletaddresss?Walletaddresss=' + val
				})
			},
			editParkImg(currentTempFilePath) {
			                //执行增加操作
			                console.log(currentTempFilePath);
			                // uni.uploadFile({
			                //  url: '链接地址',
			                //  filePath: currentTempFilePath,
			                //  name: 'file',
			                //  formData: {},
			                //  success: (res) => {
			
			                //  },
			                //  fail: (res) => {
			
			                //  },
			                // });
			
			            },
			            deleteImg(index) {
			                //删除操作 index数组中的下标
			                console.log(index);
			            },
			changeHead(){
				var that =this;
				console.log(this.$store.state.istoken);
				// // 从相册选择6张图
				uni.chooseImage({
				    count: 1,
				    sizeType: ['original'],
				    sourceType: ['album'],
				    success:res=> {
						
						// var img=res.tempFiles[0].path.slice(5);
						var img=res.tempFiles[0].path;
						 uni.uploadFile({
						            url: config.baseUrl+api.PACTURE_onload, //仅为示例，非真实的接口地址
						            filePath: img,
									header:{
										token:that.$store.state.istoken
									},
									name: 'file',
						            success: (uploadFileRes) => {
										var img2=JSON.parse(uploadFileRes.data);
										// 修改头像
										that.$api.sendRequest({
											url:api.USER_profile,
											data: {
												avatar:img2.code.url
											},
											success: res => {
												that.src=api.HOST+img2.code.url
												console.log(res.data);
											}
										});
						            }
						        })
				    }
				    });
			},
			changeTel(){
				// 修改手机号
				uni.navigateTo({
					url:'../change-Tel/change-Tel'
				})
			},
			changeAddress(){
				//修改地址
				uni.navigateTo({
					url:'../myAddress/myAddress'
				})
			},
		},
		onShow() {
			if(uni.getStorageSync('token')) {
				this.$api.sendRequest({
					url: api.MINE_userId,
					success: res => {
						this.src=api.HOST+res.data.welcome.avatar
						var shouJi_jiaMi =res.data.welcome.mobile.replace(/([0-9]{3})([0-9]{4})([0-9]{4})/, '$1****$3');
						console.log("加密后的手机号为："+shouJi_jiaMi);
						this.tel=shouJi_jiaMi
						this.user_data = res.data.welcome
					}
				});
			}
			
			// uni.getStorage({
			// 	key:'id',
			// 	success:res=>{
			// 		// 手机号加密
			// 		var shouJi = res.data;
			// 		var shouJi_jiaMi = shouJi.replace(/([0-9]{3})([0-9]{4})([0-9]{4})/, '$1****$3');
			// 		console.log("加密后的手机号为："+shouJi_jiaMi);
			// 		this.tel=shouJi_jiaMi
			// 	}
			// })
		}
	}
</script>

<style>
	.idSafe{
		background-color: #F3F3F3;
		height: 94.6vh;
	}
.warp{
		width: 94%;
		margin: auto;
	}
	
.box{
	width: 100%;
	height: 100rpx;
	background-color: #FFFFFF;
	margin: auto;
	box-shadow: 0 0 0 rgba(0,0,0,.06);
	display: flex;
	position: relative;
	border-bottom: 2rpx solid #F3F3F3;
}
.headT{
		position: absolute;
		width: 60rpx;
		height: 60rpx;
		z-index: 66;
		right: 50px;
		top: 20rpx;
	}
h3{
	line-height: 100rpx;
	margin-left: 40rpx;
	opacity: .8;
}
.go{
	width: 20rpx;
	height: 20rpx;
	position: absolute;
	right: 40rpx;
	top: 40rpx;
}
.nick{
	position: absolute;
	right: 80rpx;
	top: 30rpx;
}
.tel{
	position: absolute;
	right: 80rpx;
	top: 30rpx;
}
.address{
	position: absolute;
	right: 80rpx;
	top: 30rpx;
}
 .content {
        padding: 0 21rpx;
        margin-top: 21rpx;
		background-color: #005FDB;
    }
</style>
